<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<%@ page import = "org.apache.struts.Globals" %>

<script language="JavaScript">

<jsp:include page="/mc/common/jsutils.jsp" />

  //
  function closeWindow() {
    self.close();
  }
 
  function doSelectWithoutFindField(itemId, itemName) {
  	var idsList = new Array();
	var namesList = new Array();
	idsList = idsList.concat(itemId);
	namesList = namesList.concat(itemName);
	callParentWindow(idsList, namesList);
  }
  
  function doSelect(name, property, itemId, index) {
	var fieldName = name + '[' + index + '].' + property;
    var field = findField(fieldName);
    if (field != null) {
    	doSelectWithoutFindField(itemId, field.value);
	}// if
  }
  
  function doDoneSingleSelect() {
  	var f = document.mtPickerPopupForm;
  	var len = f.elements.length;
	var idsList = new Array();
	var namesList = new Array();
	var i = 0;
	for(i = 0; i < len; i++){
		if (f.elements[i].name == "itemIds"){
			if (f.elements[i].type.toLowerCase() == "radio") {
	        	if (f.elements[i].checked){
	        		idsList = idsList.concat(f.elements[i].value);
	        		namesList = namesList.concat(f.elements[i].id);
	        		break;
	        	}// if
			}// if
		}// if
	}// for
	if (idsList.length < <c:choose><c:when test="${mtPickerPopupForm.map.minSelection != 0}"><c:out value="${1}"/></c:when><c:otherwise><c:out value="${mtPickerPopupForm.map.minSelection}"/></c:otherwise></c:choose>) {
		alert("<bean-el:message key="mt.picker.popup.min.single.selection.required" bundle="mt.messages"/>");
		return;
	}// if
	callParentWindow(idsList, namesList);
  }
  
  function doDoneMultiSelect() {
  	var f = document.mtPickerPopupForm;
	var idsList = new Array();
	var namesList = new Array();
  	var ids = f.selectedItemIds.options;
  	var names = f.selectedItemNames.options;
  	var i = 0;
  	for (i = 0; i < ids.length; i++) {
  		idsList = idsList.concat(ids[i].value);
  		namesList = namesList.concat(names[i].value);
  	}// for
	if (idsList.length < <c:out value="${mtPickerPopupForm.map.minSelection}"/>) {
                callParentWindow(idsList, namesList); 
		return;
	}// if
  	callParentWindow(idsList, namesList);
  }
  
  function findField(fieldName) {
    var elements = document.mtPickerPopupForm.elements;
    var numElements = elements.length;
    for (var elementIndex = 0; elementIndex < numElements; elementIndex++) {
      var elementName = elements[elementIndex].name;
      if (elementName == fieldName) {
        return elements[elementIndex];
      }
    }
    return null;
  }
  
  function doAddOneItem(name, property, id, index) {
    var fieldName = name + '[' + index + '].' + property;
    var field = findField(fieldName);
    if (field != null) {
		if (doAddOneItemWithoutSubmit(id, field.value))
			document.mtPickerPopupForm.submit();
    }// if
  }
  
  function doAddOneItemWithoutSubmit(id, name) {
  	var f = document.mtPickerPopupForm;
 	var ids = f.selectedItemIds.options;
 	var i = 0;
  	for (i = 0; i < ids.length; i++) {
  		if (ids[i].value == id) {
  			alert(name + " <bean-el:message key="mt.picker.popup.already.exists" bundle="mt.messages"/>");
	  		return false;
  		}// if
  	}// for
  	var newoptionId = new Option(id, id, true, true);
  	var newoptionName = new Option(name, name, true, true);
  	f.selectedItemIds.options[f.selectedItemIds.options.length] = newoptionId;
  	f.selectedItemNames.options[f.selectedItemNames.options.length] = newoptionName;
  	return true;
  }
  
  function doDeleteOneItem(index) {
	doDeleteOneItemWithoutSubmit(index)
  	document.mtPickerPopupForm.submit();
  }
  
  function doDeleteOneItemWithoutSubmit(index) { 
	document.mtPickerPopupForm.selectedItemIds.options[index].selected = false;
	document.mtPickerPopupForm.selectedItemNames.options[index].selected = false;
  }
  
  function doAddMultiItems(name, property) {
  	var f = document.mtPickerPopupForm;
  	var checkboxes = makeItAnArrayIfNot(f.itemIds);
  	var i = 0;
  	var submitIt = false;
    var countChecked = 0;
  	for (i = 0; i < checkboxes.length; i++) {
  		if (checkboxes[i].checked) {
        countChecked++;
  	    var fieldName = name + '[' + checkboxes[i].id + '].' + property;
  			var field = findField(fieldName);
   			if (field != null) {
    			var result = doAddOneItemWithoutSubmit(checkboxes[i].value, field.value);
    			if (!submitIt) {
  	  			submitIt = result;
  		  	}// if
    		}// if
  		}// if
  	}// for
  	if (submitIt) {
  		f.submit();
  	}// if
    if (countChecked == 0) {
      alert("<bean-el:message key="mt.picker.popup.min.multi.mark.required" bundle="mt.messages"/>");
    }
  }
  
  function doDeleteMultiItems() {
  	var f = document.mtPickerPopupForm;
  	var checkboxes = makeItAnArrayIfNot(f.selectedItems);
	  var i = 0;
    var countChecked = 0;
	  for (i = 0; i < checkboxes.length; i++) {
		  if (checkboxes[i].checked) {
        countChecked++;
			  doDeleteOneItemWithoutSubmit(i)
  		}// if
	  }// for
    if (countChecked > 0) {
    	f.submit();
    }
    else {
      alert("<bean-el:message key="mt.picker.popup.min.multi.selected.removed.required" bundle="mt.messages"/>");
    }
  }
  
  function doMarkAllItemIds() {
  	doCheckAll(makeItAnArrayIfNot(document.mtPickerPopupForm.itemIds));
  }
  
  function doMarkAllSelectedItems() {
  	doCheckAll(makeItAnArrayIfNot(document.mtPickerPopupForm.selectedItems));
  }
    
  function doCheckAll(checkboxes) {
  	var i = 0;
  	for (i = 0; i < checkboxes.length; i++) {
  		if (!checkboxes[i].checked) {
  			checkboxes[i].checked = true;
  		}// if
  	}// for
  }
  
  // Form will not return an array if there is only one named element exists.
  // so use this function to create an array that contains the single element.
  // If form already returned an array, this function will not create a new array but return the original array
  function makeItAnArrayIfNot(arrayWantToBe) {
  	var undefined;
	var returnArray = arrayWantToBe;
	if (returnArray.length == undefined) {
		returnArray = new Array();
	  	returnArray = returnArray.concat(arrayWantToBe);
	}// if
	return returnArray;
  }
  
  function callParentWindow(idsList, namesList) {
	self.opener.<c:out value="${mtPickerPopupForm.map.callback}"/>(idsList, namesList);
  	self.close();
  }
  
  function doPickCategoryActionEx(name, property, oid, index) {
  	var fieldName = name + '[' + index + '].' + property;
    var field = findField(fieldName);
    if (field != null) {
	   	doPickCategoryAction(oid, field.value);
	}// if
  }
  
  function doPickCategoryAction(oid, name) {
  	document.mtPickerPopupForm.currentCategoryOid.value = oid;
	document.mtPickerPopupForm.currentCategoryName.value = name;
	document.mtPickerPopupForm.submit();
  }
  
  function doClickOnTab(url) {
  	document.mtPickerPopupForm.action = url;
	document.mtPickerPopupForm.submit();
  }
  function doClickOnGo() {
    var theSearchKey = document.mtPickerPopupForm.searchKey.value;
    document.mtPickerPopupForm.searchKey.value = theSearchKey.stringTrim();
  	document.mtPickerPopupForm.searchBtnNeverClicked.value = false;
  }
</script>
<% String ctxPath = request.getContextPath(); %>
<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
<c:set var="addImg">
<img src="<%= ctxPath %>/mc/images/action/icon_add.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.add" bundle="mt.messages"/>" title="<bean-el:message key="image.alt.add" bundle="mt.messages"/>">
</c:set>
<c:set var="removeImg">
<img src="<%= ctxPath %>/mc/images/action/icon_remove.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.remove" bundle="mt.messages"/>" title="<bean-el:message key="image.alt.remove" bundle="mt.messages"/>">
</c:set>
</logic:equal>
<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
<c:set var="selectImg">
<img src="<%= ctxPath %>/mc/images/action/icon_add.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.select" bundle="mt.messages"/>" title="<bean-el:message key="image.alt.select" bundle="mt.messages"/>">
</c:set>
</logic:notEqual>

<logic:messagesPresent name="<%=Globals.ERROR_KEY%>">
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="errorMessage"><html-el:errors /></div>
    </td>
  </tr>
</table>
</logic:messagesPresent>
<logic:messagesNotPresent name="<%=Globals.ERROR_KEY%>">
<c:set var="actionPath" value="${pager.map.url}"/>
<html-el:form action="${pageScope.actionPath}">
<html-el:hidden name="mtPickerPopupForm" property="contentTypeId"/>
<html-el:hidden name="mtPickerPopupForm" property="contentTypeName"/>
<html-el:hidden name="mtPickerPopupForm" property="currentCategoryOid"/>
<html-el:hidden name="mtPickerPopupForm" property="currentCategoryName"/>
<logic:notEqual name="mtPickerPopupForm" property="columnName" value="">
	<html-el:hidden name="mtPickerPopupForm" property="columnName"/>
</logic:notEqual>
<logic:notEqual name="mtPickerPopupForm" property="selectedTab" value="1">
	<logic:notEqual name="mtPickerPopupForm" property="searchKey" value="">
		<html-el:hidden name="mtPickerPopupForm" property="searchKey"/>
	</logic:notEqual>
	<logic:equal name="mtPickerPopupForm" property="allCategories" value="true">
		<html-el:hidden name="mtPickerPopupForm" property="allCategories"/>
	</logic:equal>
</logic:notEqual>
<html-el:hidden name="mtPickerPopupForm" property="searchBtnNeverClicked"/>
<html-el:hidden name="mtPickerPopupForm" property="callback"/>
<logic:equal name="mtPickerPopupForm" property="browseTab" value="false">
	<html-el:hidden name="mtPickerPopupForm" property="browseTab"/>
</logic:equal>
<logic:equal name="mtPickerPopupForm" property="searchTab" value="false">
	<html-el:hidden name="mtPickerPopupForm" property="searchTab"/>
</logic:equal>
<logic:equal name="mtPickerPopupForm" property="uncateTab" value="false">
	<html-el:hidden name="mtPickerPopupForm" property="uncateTab"/>
</logic:equal>
<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
	<html-el:select property="selectedItemIds" multiple="multiple" style="visibility: hidden; display: none;">
		<html-el:options name="mtPickerPopupForm" property="selectedItemIds"/>
	</html-el:select>
	<html-el:select property="selectedItemNames" multiple="multiple" style="visibility: hidden; display: none;">
		<html-el:options name="mtPickerPopupForm" property="selectedItemNames"/>
	</html-el:select>
</logic:equal>
<logic:notEqual name="mtPickerPopupForm" property="cntFilterClass" value="">
	<html-el:hidden name="mtPickerPopupForm" property="cntFilterClass"/>
</logic:notEqual>
<logic:notEqual name="mtPickerPopupForm" property="catFilterClass" value="">
	<html-el:hidden name="mtPickerPopupForm" property="catFilterClass"/>
</logic:notEqual>
<logic:notEqual name="mtPickerPopupForm" property="minSelection" value="1">
	<html-el:hidden name="mtPickerPopupForm" property="minSelection"/>
</logic:notEqual>
<logic:equal name="mtPickerPopupForm" property="rootSelection" value="false">
	<html-el:hidden name="mtPickerPopupForm" property="rootSelection"/>
</logic:equal>
<logic:notEqual name="mtPickerPopupForm" property="filterClassData" value="">
	<html-el:hidden name="mtPickerPopupForm" property="filterClassData"/>
</logic:notEqual>
<c:if test="${mtPickerPopupForm.map.searchBtnNeverClicked && not empty mtPickerPopupForm.map.defaultSearchResultIds}">
	<html-el:hidden name="mtPickerPopupForm" property="defaultSearchResultIds"/>
</c:if>
<c:if test="${!mtPickerPopupForm.map.showAllCategories}">
	<html-el:hidden name="mtPickerPopupForm" property="showAllCategories"/>
	<html-el:hidden name="mtPickerPopupForm" property="allCategories"/>
</c:if>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
	<tr>
	<td valign="top" width="100%">
	<div class="generalWrapRight">
		<div class="generalWrapLeft" style="font-size: medium;">
		<c:choose>
			<c:when test="${mtPickerPopupForm.map.categoryOnly}">
	 			<c:choose>
	   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
						<bean-el:message key="mt.picker.popup.select.channel" bundle="mt.messages"/>
		            </c:when>
					<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
						<bean-el:message key="mt.picker.popup.select.qualifier" bundle="mt.messages"/>
		            </c:when>
		            <c:otherwise>
		            	<bean-el:message key="mt.picker.popup.select.category.of.type" 
							arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
		            </c:otherwise>
				</c:choose>
			</c:when>
			<c:otherwise>
	            <bean-el:message key="mt.picker.popup.select.of.type" 
	        		arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
			</c:otherwise>
		</c:choose>
		</div>
		<input type="button" name="actionCloseWindow" class="inputButton" 
			onclick="closeWindow();"
			value='<bean-el:message key="button.close" bundle="mt.messages"/>'>
	</div>
		<bean-el:size id="tabCount" name="pagetab" property="items"/>
	<c:if test="${tabCount > 1}">
		<div>
			<c:set var="pagetabParam" value="${pager.map.urlParams}"/>
			<%@include file="/mc/common/pagetab.jsp" %>
		</div>
	</c:if>
<logic:present name="mtCategoryInfoView">
<%-- Top Section - the breadcrumb --%>
	<div class="breadcrumb">
      <logic:equal name="mtCategoryInfoView" property="viewCategory" value="true">
        <logic:empty name="mtCategoryInfoView" property="paths">
          <bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/>
        </logic:empty>
        <logic:notEmpty name="mtCategoryInfoView" property="paths">
          <a href='#' onclick="doPickCategoryAction('0', '<bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/>');">
            <bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/>
          </a>
          <logic:iterate id="path" name="mtCategoryInfoView" property="paths" indexId="i">
          	<html-el:hidden name="path" property="name" indexed='true'/>
            <!--bean:define id="currentCategoryName" name="path" property="name"/-->
            <c:set var="theCurrentCategoryName" value="${path.map.name}"/>
            &nbsp;<bean-el:message key="mt.pathSeparator" bundle="mt.messages"/>&nbsp;
            <logic:equal name="path" property="isCurrentPath" value="false">
              <a href='#' onclick="doPickCategoryActionEx('path', 'name', '<c:out value="${path.map.oid}"/>', '<c:out value="${i}"/>');">
                <c:out value="${theCurrentCategoryName}"/>
              </a>
            </logic:equal>
            <logic:equal name="path" property="isCurrentPath" value="true">
              <c:out value="${theCurrentCategoryName}"/>
            </logic:equal>
          </logic:iterate>
        </logic:notEmpty>
      </logic:equal>
    </div>
<%-- End --%>
<c:if test="${mtPickerPopupForm.map.rootSelection}">
	<logic:equal name="mtPickerPopupForm" property="skipItemsList" value="true">
		<logic:equal name="mtPickerPopupForm" property="currentCategoryOid" value="0">
			<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
				<div class="pageButtonWrap" align="left">
			    	<bean-el:message key="mt.picker.popup.select.root" bundle="mt.messages"/>
						<a href='#' onclick="doSelectWithoutFindField(0, '<bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/>');">
							<c:out value='${selectImg}' escapeXml="false"/>
						</a>
				</div>
		    </logic:notEqual>
		</logic:equal>    
	</logic:equal>
</c:if>
<%-- Subcategories section --%>
  <!--
	<c:set var="currentCategoryName">
		<bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/>
	</c:set> 
  -->
  <c:set var="theCurrentCategoryName"><bean-el:message key="mt.picker.popup.root" bundle="mt.messages"/></c:set>
	<div class="pageSubtitle" width="20%">
		<span class="left">
			<c:choose>
				<c:when test="${mtPickerPopupForm.map.currentCategoryOid == 0}">
					<c:choose>
						<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
							<bean-el:message key="mt.picker.popup.channels.within" 
		                  		arg0="${theCurrentCategoryName}" bundle="mt.messages"/>
		                </c:when>
						<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
							<bean-el:message key="mt.picker.popup.qualifier.within" 
		                  		arg0="${theCurrentCategoryName}" bundle="mt.messages"/>
		                </c:when>
		                <c:otherwise>
		                	<bean-el:message key="mt.picker.popup.categories.within" 
		                  		arg0="${theCurrentCategoryName}" bundle="mt.messages"/>
		                </c:otherwise>
		          	</c:choose>
		        </c:when>
		   		<c:otherwise>
		   			<c:choose>
		   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
							<bean-el:message key="mt.picker.popup.channels.within" 
		                  		arg0="${mtPickerPopupForm.map.currentCategoryName}" bundle="mt.messages"/>
		                </c:when>
		   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
							<bean-el:message key="mt.picker.popup.qualifier.within" 
		                  		arg0="${mtPickerPopupForm.map.currentCategoryName}" bundle="mt.messages"/>
		                </c:when>
		                <c:otherwise>
		                	<bean-el:message key="mt.picker.popup.categories.within" 
		                  		arg0="${mtPickerPopupForm.map.currentCategoryName}" bundle="mt.messages"/>
		                </c:otherwise>
		           	</c:choose>
					<!--bean:define id="currentCategoryName" name="mtPickerPopupForm" property="currentCategoryName" type="java.lang.String" / --> 
              <c:set var="theCurrentCategoryName" value="${mtPickerPopupForm.map.currentCategoryName}"/>
		        </c:otherwise>
	        </c:choose>
		</span>
	</div>
<%-- These global buttons are for multiple selection and will only show up when it's for picking category and the subcategory list is not empty --%>
<logic:equal name="mtPickerPopupForm" property="skipItemsList" value="true">
	<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
		<c:if test="${not empty mtCategoryInfoView.map.subcategories}">
		      <div class="globalButtonWrap">
		         <input type="button" name="actionMarkAll" class="globalButton"
		         	onclick="check(this.form.itemIds, this, '<bean-el:message key="button.markAll" bundle="mt.messages"/>', '<bean-el:message key="button.unmarkAll" bundle="mt.messages"/>');"
		          	value="<bean-el:message key="mt.picker.popup.mark.all" bundle="mt.messages"/>">
		   		<input type="button" name="actionAddToSelect" class="globalButton"
		        	onclick="doAddMultiItems('cat', 'nameToSave');"
					value="<bean-el:message key="mt.picker.popup.add.to.selected.items" bundle="mt.messages"/>">
		      </div>
		</c:if>
	</logic:equal>
</logic:equal>	
<%-- End --%>
	<table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
		<tr class="listHeader">
		<logic:equal name="mtPickerPopupForm" property="categoryOnly" value="true">
			<th id="catBtns">&nbsp;</th>
		</logic:equal>
	  	<th id="Name" align="left">
			<c:choose>
   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
					<bean-el:message key="mt.picker.popup.channel" bundle="mt.messages"/>
	            </c:when>
				<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
					<bean-el:message key="mt.picker.popup.qualifier" bundle="mt.messages"/>
	            </c:when>
	            <c:otherwise>
	            	<bean-el:message key="mt.picker.popup.cateogry" bundle="mt.messages"/>
	            </c:otherwise>
			</c:choose>
	  	</th>
	  	<logic:equal name="mtPickerPopupForm" property="skipItemsList" value="true">
		  	<th id="Actions" align="left" nowrap>
		    	<bean-el:message key="mt.header.actions" bundle="mt.messages"/>
		  	</th>
		</logic:equal>
		</tr>
		<c:choose>
		  <c:when test="${not empty mtCategoryInfoView.map.subcategories}">
		    <c:forEach var="cat" items="${mtCategoryInfoView.map.subcategories}" varStatus="status">
		    	<html-el:hidden name="cat" property="nameToSave" indexed='true'/>
		    	<html-el:hidden name="cat" property="name" indexed='true'/>
			    <c:choose>
					<c:when test="${(status.count + 1) % 2 == 0}">
					  <tr class="listEven">
					</c:when> 
					  	    <c:otherwise>
					  <tr class="listOdd">
					</c:otherwise>
				</c:choose>
				<c:set var="thisId" value="${cat.map.oid}"/>
				<logic:equal name="mtPickerPopupForm" property="categoryOnly" value="true">
				<td headers="checkBtns" align="center">
					<c:if test="${cat.map.canSelect}">
						<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
							<input type="checkbox" name="itemIds" value="<c:out value='${thisId}'/>" 
                onclick="update(this.form.itemIds, this.form.actionMarkAll, '<bean-el:message key="button.markAll" bundle="mt.messages"/>', '<bean-el:message key="button.unmarkAll" bundle="mt.messages"/>');" 
                id='<c:out value="${status.count - 1}"/>'/>
						</logic:equal>
						<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
							<input type="radio" name="itemIds" value="<c:out value='${thisId}'/>" id='<c:out value="${cat.map.nameToSave}"/>'/>
						</logic:notEqual>
					</c:if>
				</td>
				</logic:equal>
				<td headers="Name">
					<a href='#' onclick="doPickCategoryActionEx('cat', 'name', '<c:out value="${cat.map.oid}"/>', '<c:out value="${status.count - 1}"/>');">
                		<c:out value="${cat.map.name}"/>
              		</a>
              	</td>
              	<logic:equal name="mtPickerPopupForm" property="skipItemsList" value="true">
					<td headers="Actions">
						<c:if test="${cat.map.canSelect}">
							<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
								<a href='#' onclick="doAddOneItem('cat', 'nameToSave', <c:out value='${thisId}'/>, '<c:out value="${status.count - 1}"/>');">
									<c:out value='${addImg}' escapeXml="false"/>
								</a>
					        </logic:equal>
					        <logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
								<a href='#' onclick="doSelect('cat', 'nameToSave', <c:out value='${thisId}'/>, '<c:out value="${status.count - 1}"/>');">
									<c:out value='${selectImg}' escapeXml="false"/>
								</a>
					        </logic:notEqual>
				        </c:if>
				 	</td>
			    </logic:equal>
		        </tr>
		    </c:forEach>
		  </c:when>
		  <c:otherwise>
		        <tr class="listOdd">
		          <td align="center" colspan="3">
		 			<c:choose>
		   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
							<bean-el:message key="mt.channels.noFound" bundle="mt.messages"/>
			            </c:when>
						<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
							<bean-el:message key="mt.qualifiers.noFound" bundle="mt.messages"/>
			            </c:when>
			            <c:otherwise>
			            	<bean-el:message key="mt.categories.noFound" bundle="mt.messages"/>
			            </c:otherwise>
					</c:choose>
		          </td>
		        </tr>
		  </c:otherwise>
		</c:choose>
	</table>
<%-- End --%>
</logic:present>
<logic:equal name="mtPickerPopupForm" property="skipItemsList" value="false">
<%-- Content items list section subtitle --%>
<logic:equal name="mtPickerPopupForm" property="selectedTab" value="1">
		<div class="pageButtonWrap" align="left">
			<span class="left">
				<bean-el:message key="mt.picker.popup.search" bundle="mt.messages"/>:
			</span>
			<html-el:text name="mtPickerPopupForm" property="searchKey"  onkeypress="doClickOnGo();" maxlength="80"/>
			<input type="submit" name="goBtn" class="pageButton"
				onclick="doClickOnGo();"
		  		value='<bean-el:message key="button.goto" bundle="mt.messages"/>'>
		</div>
		<logic:equal name="mtPickerPopupForm" property="categoryOnly" value="false">
			<c:if test="${mtPickerPopupForm.map.showAllCategories}">
				<div class="pageButtonWrap" align="left">
					<span class="left"/>
					<html-el:checkbox name="mtPickerPopupForm" property="allCategories"/><bean-el:message key="mt.picker.popup.include.all.categories" bundle="mt.messages"/>
				</div>
			</c:if>
		</logic:equal>
</logic:equal>
      <div class="pageSubtitle" width="20%">
      <logic:equal name="mtPickerPopupForm" property="selectedTab" value="0">
        <span class="left">
        	<bean-el:message key="mt.picker.popup.generic.in" 
	     		arg0="${mtPickerPopupForm.map.contentTypeName}" arg1="${theCurrentCategoryName}" bundle="mt.messages"/>  
        </span>
      </logic:equal>
      <logic:equal name="mtPickerPopupForm" property="selectedTab" value="1">
        <span class="left">
        	<bean-el:message key="mt.picker.popup.search.results" bundle="mt.messages"/>         
        </span>
      </logic:equal>
      <logic:equal name="mtPickerPopupForm" property="selectedTab" value="2">
        <span class="left">
        	<bean-el:message key="mt.picker.popup.uncategorized.items" bundle="mt.messages"/>        
        </span>
      </logic:equal>
      </div>
<%-- End --%>
<%-- These global buttons are for multiple selection and will only show up when the list is not empty --%>
<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
	<c:if test="${not empty list}">
	      <div class="globalButtonWrap">
	         <input type="button" name="actionMarkAll" class="globalButton"
	         	onclick="check(this.form.itemIds, this, '<bean-el:message key="button.markAll" bundle="mt.messages"/>', '<bean-el:message key="button.unmarkAll" bundle="mt.messages"/>');"
	          	value="<bean-el:message key="mt.picker.popup.mark.all" bundle="mt.messages"/>">
	        <input type="button" name="actionAddToSelect" class="globalButton"
	        	onclick="doAddMultiItems('item', 'nameToSave');"
				value="<bean-el:message key="mt.picker.popup.add.to.selected.items" bundle="mt.messages"/>">
	      </div>
	</c:if>
</logic:equal>	
<%-- End --%>
<%-- This section is for content items list --%>
		<table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        	<tr class="listHeader">
          	<th id="RadioBtns">&nbsp;</th>
          	<th id="Name" align="left">
				<bean-el:message key="mt.picker.popup.add.to.selected.items" bundle="mt.messages"/>
          	</th>
          	<th id="Actions" align="left" nowrap>
            	<bean-el:message key="mt.header.actions" bundle="mt.messages"/>
          	</th>
        	</tr>
			<c:choose>
			  <c:when test="${not empty list}">
			    <c:forEach var="item" items="${list}" varStatus="status">
			    	<html-el:hidden name="item" property="nameToSave" indexed='true'/>
				    <c:choose>
						<c:when test="${(status.count + 1) % 2 == 0}">
						  <tr class="listEven">
						</c:when> 
						  	    <c:otherwise>
						  <tr class="listOdd">
						</c:otherwise>
					</c:choose>
					<td headers="RadioBtns" align="center">
			            <c:set var="thisId" value="${item.map.id}"/>
			            <c:if test="${item.map.canSelect}">
				            <logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
								<input type="checkbox" name="itemIds" value="<c:out value='${thisId}'/>" 
                  onclick="update(this.form.itemIds, this.form.actionMarkAll, '<bean-el:message key="button.markAll" bundle="mt.messages"/>', '<bean-el:message key="button.unmarkAll" bundle="mt.messages"/>');"
                  id='<c:out value="${status.count - 1}"/>'/>
							</logic:equal>
							<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
								<input type="radio" name="itemIds" value="<c:out value='${thisId}'/>" id='<c:out value="${item.map.name}"/>'/>
							</logic:notEqual>
						</c:if>
			       	</td>
		       		<td headers="Name"><c:out value="${item.map.name}"/></td>
					<td headers="Actions">
						<c:if test="${item.map.canSelect}">
							<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
								<a href='#' onclick="doAddOneItem('item', 'nameToSave', <c:out value='${thisId}'/>, '<c:out value="${status.count - 1}"/>');">
									<c:out value='${addImg}' escapeXml="false"/>
								</a>
							</logic:equal>
							<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
								<a href='#' onclick="doSelect('item', 'nameToSave', <c:out value='${thisId}'/>, '<c:out value="${status.count - 1}"/>');">
									<c:out value='${selectImg}' escapeXml="false"/>
								</a>
							</logic:notEqual>
						</c:if>
					</td>
			        </tr>
			    </c:forEach>
			  </c:when>
			  <c:otherwise>
			        <tr class="listOdd">
			          <td align="center" colspan="3">
			          	<c:choose>
				          	<c:when test="${mtPickerPopupForm.map.categoryOnly}">
					 			<c:choose>
					   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
										<bean-el:message key="mt.channels.noFound" bundle="mt.messages"/>
						            </c:when>
									<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
										<bean-el:message key="mt.qualifiers.noFound" bundle="mt.messages"/>
						            </c:when>
						            <c:otherwise>
						            	<bean-el:message key="mt.categories.of.type.noFound" 
											arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
						            </c:otherwise>
								</c:choose>
							</c:when>
							<c:otherwise>
					            <bean-el:message key="mt.items.noFound" 
					        		arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
			        		</c:otherwise>
						</c:choose>
			          </td>
			        </tr>
			  </c:otherwise>
			</c:choose>
		</table>
<%-- End --%>
		<c:if test="${not empty list}">
			<jsp:include page="/mc/common/pager.jsp" />
		</c:if>
</logic:equal>
<%-- multiple selection section --%>
<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true"> 
      <div class="pageSubtitle" width="20%">
        <span class="left">
        	<bean-el:size id="count" name="mtPickerPopupForm" property="selectedItemIds"/>
        	<bean-el:message key="mt.picker.popup.selected.items" 
	                  			arg0="${count}" bundle="mt.messages"/>
        </span>
		<div class="right" width="80%">
        </div>
      </div>
<%-- These global buttons are for multiple selection and will only show up when the "Selected items list is not empty --%>
	<c:if test="${not empty mtPickerPopupForm.map.selectedItemIds}">
	      <div class="globalButtonWrap">
	         <input type="button" name="actionSelectAll" class="globalButton"
	         	onclick="check(this.form.selectedItems, this);"
	          	value="<bean-el:message key="button.selectAll" bundle="mt.messages"/>">
	         <input type="button" name="actionRemove" class="globalButton"
	    		onclick="doDeleteMultiItems();"
		  		value="<bean-el:message key="button.remove" bundle="mt.messages"/>">
	      </div>
	</c:if>
<%-- End --%>
<%-- This section is for "Selected items" list --%>
		<table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        	<tr class="listHeader">
          	<th id="ChkBtns">&nbsp;</th>
          	<th id="Name" align="left">
				<bean-el:message key="mt.picker.popup.name" bundle="mt.messages"/>
          	</th>
          	<th id="Actions" align="left" nowrap>
            	<bean-el:message key="mt.header.actions" bundle="mt.messages"/>
          	</th>
        	</tr>
			<c:choose>
			  <c:when test="${not empty mtPickerPopupForm.map.selectedItemIds}">
			    <c:forEach var="item" items="${mtPickerPopupForm.map.selectedItemIds}" varStatus="status">
				    <c:choose>
						<c:when test="${(status.count + 1) % 2 == 0}">
						  <tr class="listEven">
						</c:when> 
						<c:otherwise>
						  <tr class="listOdd">
						</c:otherwise>
					</c:choose>
					<td headers="ChkBtns" align="center">
						<input type="checkbox" name="selectedItems" value='<c:out value="${item}"/>' 
              onclick="update(this.form.selectedItems, this.form.actionSelectAll);"
              id='<c:out value="${mtPickerPopupForm.map.selectedItemNames[status.count - 1]}"/>'/>
			       	</td>
		       		<td headers="Name"><c:out value="${mtPickerPopupForm.map.selectedItemNames[status.count - 1]}"/></td>
					<td headers="Actions">
						<a href='#' onclick="doDeleteOneItem(<c:out value="${status.count - 1}"/>);">
							<c:out value='${removeImg}' escapeXml="false"/>
						</a>
			        </td>
					</tr>
				</c:forEach>
			  </c:when>
			  <c:otherwise>
			        <tr class="listOdd">
			          <td align="center" colspan="3">
			          	<c:choose>
				          	<c:when test="${mtPickerPopupForm.map.categoryOnly}">
					 			<c:choose>
					   				<c:when test="${mtPickerPopupForm.map.contentTypeId == 301}">
										<bean-el:message key="mt.channels.noFound" bundle="mt.messages"/>
						            </c:when>
									<c:when test="${mtPickerPopupForm.map.contentTypeId == 315}">
										<bean-el:message key="mt.qualifiers.noFound" bundle="mt.messages"/>
						            </c:when>
						            <c:otherwise>
						            	<bean-el:message key="mt.categories.of.type.noFound" 
											arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
						            </c:otherwise>
								</c:choose>
							</c:when>
							<c:otherwise>
					            <bean-el:message key="mt.items.noFound" 
					        		arg0="${mtPickerPopupForm.map.contentTypeName}" bundle="mt.messages"/>
			        		</c:otherwise>
						</c:choose>
			          </td>
			     	</tr>
			  </c:otherwise>
			</c:choose>
		</table>
<%-- End multiple selection section--%>
</logic:equal>
<%-- Bottom section --%>
      <div class="pageButtonWrap" align="right">
        <input type="button" name="actionCancel" class="pageButton" 
      		onclick="closeWindow();"
   			value='<bean-el:message key="button.cancel" bundle="mt.messages"/>'>
   		<logic:equal name="mtPickerPopupForm" property="multiSelect" value="true">
			<input type="button" name="actionDone" class="pageButton"
     				onclick="doDoneMultiSelect();"
   					value='<bean-el:message key="button.update" bundle="mt.messages"/>'>
		</logic:equal>
		<logic:notEqual name="mtPickerPopupForm" property="multiSelect" value="true">
			<input type="button" name="actionDone" class="pageButton"
     				onclick="doDoneSingleSelect();"
   					value='<bean-el:message key="button.select" bundle="mt.messages"/>'>
		</logic:notEqual>
      </div>
<%-- End --%>
</table>
</html-el:form>
</logic:messagesNotPresent>
